//@ts-ignore,引入请求函数
import { requestHttp } from "@/utils/requestHttp.ts";

//@ts-ignore,引入类型约束文件


/**
 * 数据大屏相关请求api模块
*/


//查询某一天平台会员用户的注册量
export const reqUserList = (startDate:string, endDate:string) => {
    return requestHttp<any>({
        url:"/manage/members/time",
        method:"get",
        params:{
            startDate:startDate,
            endDate:endDate
        }
    })
}

//查询某一天订单创建量
export const reqOrderList = (startDate:string, endDate:string) => {
    return requestHttp<any>({
        url:"/manage/orders",
        method:"post",
        data:{
            startDate:startDate,
            endDate:endDate
        }
    })
}

//查询所有的用户地址信息 (地址表中的所有数据-判断用户分布省份情况,map地图)
export const reqUserAddressList = () => {
    return requestHttp<any>({
        url:"/manage/user/address",
        method:"get"
    })
}

//查询所有的商品信息，根据销量进行降序排序 （前端截取5项进行展示）
export const reqCommodityListSort = (fieldName:string = "commodity_sales", sortRule:string = "desc") => {
    return requestHttp<any>({
        url:"/manage/commodity/sort",
        method:"get",
        params:{
            fieldName:fieldName,
            sortRule:sortRule
        }
    })
}

//查询平台会员用户数
export const reqMemberCount = () => {
    return requestHttp<any>({
        url:"/manage/members/count",
        method:"get"
    })
}

//查询网站商品分类数
export const reqCommodityCategory = () => {
    return requestHttp<any>({
        url:"/manage/category/all",
        method:"get"
    })
}

//查询平台商品总销售额(返回订单状态为已完成的所有订单，前端遍历订单信息，计算总的销售额)
//查询平台订单详情(订单状态:已完成)orderState = "已完成"
//查询平台订单详情(订单状态:待发货)orderState = "待发货"
export const reqOrderListByState = (orderState:string) => {
    return requestHttp<any>({
        url:"/manage/orders/state",
        method:"get",
        params:{
            orderState:orderState
        }
    })
}

//查询平台商品总数(接口返回所有的商品信息，total字段为商品总数)
export const reqAllCommodityList = () => {
    return requestHttp<any>({
        url:"/manage/commodity/all",
        method:"get"
    })
}